package seismosurfer.gui;

import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;

import com.bbn.openmap.gui.OverviewMapHandler;
import com.bbn.openmap.gui.WindowSupport;

/**
 * An extension to OverviewMapHandler that adapts 
 * this component for the seismo-Surfer applet needs.
 *
 */
public class SeismoOverviewMapHandler extends OverviewMapHandler {
    
    private static final long serialVersionUID = 2519305008209151616L;

    protected JFrame frame = null;

    public SeismoOverviewMapHandler() {
        super();
    }

    public ActionListener getOverviewFrameActionListener() {
        return new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                WindowSupport ws = getWindowSupport();

                int w = INITIAL_WIDTH;
                int h = INITIAL_HEIGHT;
                Dimension dim = ws.getComponentSize();
                if (map != null && dim != null) {
                    w = (int) dim.getWidth();
                    h = (int) dim.getHeight();
                }

                int x = 10;
                int y = 10;

                Point loc = ws.getComponentLocation();
                if (loc != null) {
                    x = (int) loc.getX();
                    y = (int) loc.getY();
                }               

                ws.displayInWindow(frame, x, y, w, h);
            }
        };
    }

}
